package cn.rengy.isql;

import java.io.Serializable;

public class Page implements Serializable {
		protected int pageNumber;//页码
		protected int pageSize ;//每页条数
		protected long totalCount ;//总条数
		protected int totalPage;//总页数
		//protected String orderBy ;//字段名
		//protected String ascOrDesc;//顺序
		//protected String alias;//orderby 别名
		public Page(int pageNumber, int pageSize, long totalCount){
			this.pageNumber = pageNumber <1?1: pageNumber;
			this.pageSize=pageSize;
			this.totalCount=totalCount;
			this.totalPage=(int)((totalCount / pageSize)+(totalCount % pageSize == 0 ? 0 : 1));
			//this.ascOrDesc =ascOrDesc;
			//this.orderBy =orderBy;
			//this.alias=alias;
		}
		public boolean hasNext(){
			return pageNumber <totalPage;
		}
		public void next(){
			pageNumber++;
		}
		public long getStartRow(){
			//不转换会有溢出bug
			return (long) (pageNumber - 1) *pageSize;
		}

		public long getPageNumber() {
			return pageNumber;
		}

		public void setPageNumber(int pageNumber) {
			this.pageNumber = pageNumber;
		}

		public long getPageSize() {
			return pageSize;
		}

		public void setPageSize(int pageSize) {
			this.pageSize = pageSize;
		}

		public long getTotalCount() {
			return totalCount;
		}

		public void setTotalCount(long totalCount) {
			this.totalCount = totalCount;
		}


		public int getTotalPage() {
			return totalPage;
		}

		
		
	}